<template>
  <div class="my-profile">
    <!-- 导航栏 -->
    <van-nav-bar
      class="page-nav-bar"
      left-arrow
      title="个人资料"
      @click-left="$router.back()"
    ></van-nav-bar>
    <!-- /导航栏 -->

    <!-- 个人资料 -->
    <van-cell title="头像" is-link>
      <van-image
        class="img"
        fit="cover"
        :src="user.photo"
        round
      />
    </van-cell>
    <van-cell title="昵称" :value="user.name" is-link></van-cell>
    <van-cell title="性别" :value="user.gender===1?'女':'男'" is-link></van-cell>
    <van-cell title="生日" :value="user.birthday" is-link></van-cell>
  </div>
</template>

<script>
// 获取用户个人资料
import { getUserProfile } from '@/api/user'
export default {
  name: 'MyProfile',
  components: {},
  props: {},
  data () {
    return {
      user: {}
    }
  },
  created () {
    this.getUserProfile()
  },
  mounted () {},
  methods: {
    async getUserProfile () {
      try {
        const { data } = await getUserProfile()
        console.log(data)
        this.user = data.data
      } catch (err) {
        this.$toast('获取用户个人资料失败')
      }
    }
  }
}
</script>

<style scoped lang="less">
.my-profile{
  .img{
    width: 60px;
    height: 60px;
  }
}
</style>
